package org.slusk.thynwor.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class SimpleCsv {
	public ArrayList<ArrayList<String>> data;
	
	public SimpleCsv(File file) throws IOException {
		BufferedReader in = new BufferedReader(new FileReader(file));
		data = new ArrayList<ArrayList<String>>(1000);
		String line;
		String[] tokens;
		
		while ((line = in.readLine()) != null) {
			tokens = line.split(",");
			ArrayList<String> list = new ArrayList<String>(tokens.length);
			for (String token : tokens) list.add(token);
			data.add(list);
		}
		in.close();
	}
	
	public String get(int row, int col) {
		return data.get(row).get(col);
	}
	
	public int getNumRows() {
		return data.size();
	}
	
	public int getNumColsAtRow(int row) {
		return data.get(row).size();
	}
}